package com.cmyshare.design.compositePattern;

import java.util.List;

/**
 * @author cmy
 * @version 1.0
 * @date 2024/6/16 23:16
 * @description 测试类
 */
public class Test {
    public static void main(String[] args) {
        //定义项目经理
        Employer pm = new ProjectManager("项目经理");
        //定义项目助理
        Employer pa = new ProjectAssistant("项目助理");
        //定义程序员
        Employer programmer1 = new Programmer("程序员一");
        Employer programmer2 = new Programmer("程序员二");

        //进行对象组合
        pm.add(pa);//为项目经理添加项目助理
        pm.add(programmer1);//为项目经理添加程序员1
        pm.add(programmer2);//为项目经理添加程序员2

        //获取组合对象List<Employer>
        List<Employer> ems = pm.getEmployers();
        for (Employer em : ems) {
            System.out.println(em.getName());
        }
    }
}
